package com.wangrui.client.grid;


import java.util.List;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.RecordList;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.wangrui.client.GreetingService;
import com.wangrui.client.GreetingServiceAsync;
import com.wangrui.client.data.BeanSipfa01DTO;
import com.wangrui.client.record.Sipfa01Record;

public class Sipfa01Grid extends ListGrid{
	
	public Sipfa01Grid(){
		
		setWidth100();   
        setHeight100();   
        setShowAllRecords(true);
        setAlign(Alignment.CENTER);
        setAutoFitAllText(getTitleField());
      
//        setShowFilterEditor(true); 
//        setFilterOnKeypress(true);   
        
        ListGridField ocdateField = new ListGridField("OC_DATE", "日期", 60);   
//        countryCodeField.setAlign(Alignment.CENTER);   
//        countryCodeField.setType(ListGridFieldType.IMAGE);   
//        countryCodeField.setImageURLPrefix("flags/16/");   
//        countryCodeField.setImageURLSuffix(".png");   
  
        ListGridField zqgsdmField = new ListGridField("ZQGSDM", "证券公司代码");   
        ListGridField zqgsmcoField = new ListGridField("ZQGSMC", "证券公司名称");   
        ListGridField jscyrdmField = new ListGridField("JSCYRDM", "结算参与人代码");
        ListGridField jjxsrdmField = new ListGridField("JJXSRDM", "基金销售人代码");   
        ListGridField jscyrqsbhField = new ListGridField("JSCYRQSBH", "结算参与人清算编号");   
        ListGridField jscyrjszhField = new ListGridField("JSCYRJSZH", "计算参与人结算账户");   
        ListGridField sjrqField = new ListGridField("SJRQ", "数据日期", 128); 
        
        setFields(ocdateField,zqgsdmField,zqgsmcoField,jscyrdmField,jjxsrdmField,jscyrqsbhField,jscyrjszhField,sjrqField);
        
        setCanResizeFields(true);   
          
        GreetingServiceAsync getSipfa01Service = GreetingService.Util.getInstance();
        
        AsyncCallback cb_getSipfa01 = new AsyncCallback(){

				public void onFailure(Throwable caught) {}

				public void onSuccess(Object reuslt) {

				List data = (List)reuslt;
				 BeanSipfa01DTO[] array = new BeanSipfa01DTO[data.size()];
				// ListGridRecord[] sipfa01list = new ListGridRecord[data.size ()];
				 RecordList sipfa01list = new RecordList();
				   for (int i = 0; i < data.size(); i++) {

	                    array[i] = (BeanSipfa01DTO) data.get(i);
	                    
	                    Sipfa01Record sipfa01Record = new Sipfa01Record(array[i].OC_DATE, array[i].ZQGSDM, array[i].ZQGSMC, array[i].JSCYRDM, array[i].JJXSRDM, array[i].JSCYRQSBH, array[i].JSCYRJSZH, array[i].SJRQ);
	                   
	                    sipfa01list.add(sipfa01Record);
	                    System.out.println("打印返回的数据："+array[i].OC_DATE);
	                }
				
				
				setData(sipfa01list);

			}
        	
        };getSipfa01Service.getSipfa01(cb_getSipfa01);
	}
	
          
	
//   public static RecordList getSipfa01Record(){
//	   
//	   RecordList sipfa01List = new RecordList();
//	   
//	   String[] OC_DATE = {"20120314","20120315"};
//	   String[] ZQGSDM = {"10870000","10870000"};
//	   String[] ZQGSMC = {"西部证券股份有限公司","西部证券股份有限公司"};
//	   String[] JSCYRDM={"200107","200107"};
//	   String[] JJXSRDM={"669","669"};
//	   String[] JSCYRJSZH={"jsa04","jsa04"};
//	   String[] JSCYRQSBH={"237200","237200"};
//	   String[] SJRQ={"20120228","20120228"};
//	   for(int i =0;i<2;i++){
//		   
//		   Sipfa01Record m = new Sipfa01Record(OC_DATE[i],ZQGSDM[i],ZQGSMC[i],
//				   JSCYRDM[i],JJXSRDM[i],JSCYRJSZH[i],JSCYRQSBH[i],SJRQ[i]);
//		   
//		   sipfa01List.add(m);
//	   }
//	   
//	   return sipfa01List;
//   }


}
